var ul=$("#rebate .rebate_list");
var start=0,page=1,showNumber=10;
var isload=true;
var contextPath = $("#contextPath").val();
var shoppingcartTips = $('.shoppingcart__tips');
$(function() {
	dataInit();
});

function dataInit(){
	$.ajax({
		url:contextPath+"/bill/biiList",
		type:"post",
		async:true,
		dataType:"json",
		data:{start:start,showNumber:showNumber},
		success : function(data, textStatus) {
			$(".lodingStyle").hide();
			var state = data.result.state;
			html='';
			if(state==1){
				if(data.billList.length>0){
					var type="";
					var status="";
					var symbol="";
					$.each(data.billList,function(i,v){
						if(v.type=="01"){
							type="消费";
						}else if(v.type=="02"){
							type="充值";
						}else if(v.type=="03"){
							type="消费佣金";
						}else if(v.type=="06"){
							type="提现";
						}else if(v.type=="07"){
							type="返现";
						}
						if(v.moneyStatus=="01"){
							status="rebate_status rebate_status_yes";
							symbol="+";
						}else{
							status="rebate_status rebate_status_no";
							symbol="-";
						}
						var xianjin ='';
						if(v.money != null){
							xianjin = symbol+''+v.money+"现金";
						}
						var jifen ='';
						if(v.points != 0){
							jifen = symbol+''+v.points+"兑换券";
						}
						html+='<li class="annal_item"><span class="rebate_time">'+v.createTime+'</span><span class="rebate_money">'+xianjin+' '+jifen+'</span><span class="'+status+'">'+type+'</span></li>';
					});
					ul.append(html);
					start=page*showNumber;
					page++;
					if(data.billList == showNumber){
						isload = true;	
					}
				}
				goodsIsNull();
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown){
			layer.open({
			    content:textStatus,
			    time: 2
			});
		}
	});		
}

function goodsIsNull(){
	if(ul.find(".annal_item").length==0){
		shoppingcartTips.css('display','flex');
	}else{
		shoppingcartTips.hide();
	}
}

dropload.scroll(function(t){
	if(t<5&&isload){
		$(".lodingStyle").show();
		isload = false;
		dataInit();
	}
});
